import React, { useState, useEffect } from 'react'
import { Card } from 'antd';
import address from '../address';

const { Meta } = Card;
let token = '' || localStorage.getItem('token');

const Main = () => {
    const [banner, setbanner] = useState([])
    useEffect(() => {

        fetch(address + `/wxuser/banner`,
            {
                method: 'GET',
                mode: 'cors',
                headers: {
                    'authorization': token
                },
            })
            .then(res => res.json())
            .then(res => {
                setbanner(res)
            })
    }, [])
    return (
        <div>
            {
                banner.map((item, idx) => (
                    <Card
                        key={idx}
                        hoverable
                        style={{ width: 240 ,display:'inline-block',marginRight:10}}
                        cover={<img alt="example" src={item.path} />}
                    >
                        <Meta title={idx+1} description="导航图" />
                    </Card>
                ))
            }
        </div>
    )
}

export default Main;
